#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# Copyright 2010 Boštjan Seničar
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#	http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

import pango
#import pygtk
import gtk

class atob_view:
	
	def __init__(self,parent,row):
		self.parent = parent
		self.row = row
		
		# get the tree selection
		selection = self.parent.tree.get_selection()
		
		#from tree selection get treemodel and treeiter
		treemodel, treeiter = selection.get_selected()
		signature = treemodel.get_value(treeiter,2)
		
		data = self.parent.profile.tag_data(self.row)
		
		title = self.parent.profile.public_tags[signature]
		self.parent.frame_label.set_text("<b>" + title + "</b>")
		self.parent.frame_label.set_use_markup(True)
		
		self.atob(data)
	
	def atob(self,data=None):
		child = self.parent.wTree.get_object('atob')
		
		for i in range(1,13):
			setattr(self,'e'+str(i)+'_entry', self.parent.wTree.get_object('e'+str(i)+'_entry'))
			
		input_channels, output_channels, matrix = self.parent.profile.lutAtoBType(data)
		
		for i in range(1,13):
			func = getattr(self,'e'+str(i)+'_entry')
			func.set_text('%.6f' % matrix[i-1])
		
		self.parent.replace_child(child)
		
			